/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.app.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.modules.system.service.IDictService;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.app.entity.AppAreaPlace;
import org.springblade.modules.app.vo.AppAreaPlaceVO;
import org.springblade.modules.app.wrapper.AppAreaPlaceWrapper;
import org.springblade.modules.app.service.IAppAreaPlaceService;
import org.springblade.core.boot.ctrl.BladeController;

/**
 * 坐标信息 控制器
 *
 * @author Blade
 * @since 2019-04-15
 */
@RestController
@AllArgsConstructor
@RequestMapping("/appareaplace")
@Api(value = "坐标信息", tags = "坐标信息接口")
public class AppAreaPlaceController extends BladeController {

	private IAppAreaPlaceService appAreaPlaceService;

	private IDictService dictService;

	/**
	* 详情
	*/
	@GetMapping("/detail")
	@ApiOperation(value = "详情", notes = "传入appAreaPlace", position = 1)
	public R<AppAreaPlaceVO> detail(AppAreaPlace appAreaPlace) {
		AppAreaPlace detail = appAreaPlaceService.getOne(Condition.getQueryWrapper(appAreaPlace));
		AppAreaPlaceWrapper appAreaPlaceWrapper = new AppAreaPlaceWrapper(dictService);
		return R.data(appAreaPlaceWrapper.entityVO(detail));
	}

	/**
	* 分页 坐标信息
	*/
	@GetMapping("/list")
	@ApiOperation(value = "分页", notes = "传入appAreaPlace", position = 2)
	public R<IPage<AppAreaPlaceVO>> list(AppAreaPlace appAreaPlace, Query query) {
		IPage<AppAreaPlace> pages = appAreaPlaceService.page(Condition.getPage(query), Condition.getQueryWrapper(appAreaPlace));
		AppAreaPlaceWrapper appAreaPlaceWrapper = new AppAreaPlaceWrapper(dictService);
		return R.data(appAreaPlaceWrapper.pageVO(pages));
	}

	/**
	* 自定义分页 坐标信息
	*/
	@GetMapping("/page")
	@ApiOperation(value = "分页", notes = "传入appAreaPlace", position = 3)
	public R<IPage<AppAreaPlaceVO>> page(AppAreaPlaceVO appAreaPlace, Query query) {
		IPage<AppAreaPlaceVO> pages = appAreaPlaceService.selectAppAreaPlacePage(Condition.getPage(query), appAreaPlace);
		return R.data(pages);
	}

	/**
	* 新增 坐标信息
	*/
	@PostMapping("/save")
	@ApiOperation(value = "新增", notes = "传入appAreaPlace", position = 4)
	public R save(@Valid @RequestBody AppAreaPlace appAreaPlace) {
		return R.status(appAreaPlaceService.save(appAreaPlace));
	}

	/**
	* 修改 坐标信息
	*/
	@PostMapping("/update")
	@ApiOperation(value = "修改", notes = "传入appAreaPlace", position = 5)
	public R update(@Valid @RequestBody AppAreaPlace appAreaPlace) {
		return R.status(appAreaPlaceService.updateById(appAreaPlace));
	}

	/**
	* 新增或修改 坐标信息
	*/
	@PostMapping("/submit")
	@ApiOperation(value = "新增或修改", notes = "传入appAreaPlace", position = 6)
	public R submit(@Valid @RequestBody AppAreaPlace appAreaPlace) {
		return R.status(appAreaPlaceService.saveOrUpdate(appAreaPlace));
	}

	
	/**
	* 删除 坐标信息
	*/
	@PostMapping("/remove")
	@ApiOperation(value = "删除", notes = "传入ids", position = 7)
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(appAreaPlaceService.removeByIds(Func.toIntList(ids)));
	}

	
}
